package com.iddaa.web.util;

import java.util.ArrayList;
import java.util.List;

import com.iddaa.core.exception.ErrorCode;
import com.iddaa.core.exception.IddaaException;


public class Response {

	private List<Integer> errors = new ArrayList<Integer>();
	private Object data;
	private boolean valid = true;

	public Response() {
	}
	
	public Response(Object data) {
		super();
		this.data = data;
	}

	public void addError(Throwable exception) {
		if (exception instanceof IddaaException) {
			errors.add(((IddaaException) exception).getCode());
		} else {
			errors.add(ErrorCode.GENERIC_ERROR);
		}
		valid = false;
	}

	public void setData(Object data) {
		this.data = data;
	}

	public Object getData() {
		return data;
	}

	public boolean isValid() {
		return valid;
	}

	public List<Integer> getErrors() {
		return errors;
	}



}
